<template>
  <div >
    <el-form
        ref="form"
        :label-position="labelPosition"
        label-width="120px"
        :model="form"
        :rules="rules"
        size="small"
    >
      <el-tabs style="" tabPosition="top" type="border-card">
        <el-tab-pane>
          <span slot="label"><i class="el-icon-date"></i> 业务类型</span>
          <!-- 表格表单1 -->
          <el-card>
            <el-row>
              <el-col :span="6">
                <el-form-item label="应聘者" prop="userName">
                  <el-input v-model="form.userName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="毕业时间" prop="graduationTime">
                  <el-input v-model="form.graduationTime"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="期望薪资" prop="salaryExpectation">
                  <el-input v-model="form.salaryExpectation"></el-input>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item label="毕业院校" prop="graduationSchool">
                  <el-input v-model="form.graduationSchool"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="专业" prop="maJor">
                  <el-input v-model="form.maJor"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="工作年限" prop="workYear">
                  <el-input v-model="form.workYear"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item label="应聘岗位" prop="gangWei">
                  <el-input v-model="form.gangWei"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="用人部门" prop="departMent">
                  <el-input v-model="form.departMent"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="项目组" prop="workGrop">
                  <el-input v-model="form.workGrop"></el-input>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row>
              <el-col :span="18">
                <el-form-item label="上传简历" prop="gangWei">
                  <el-upload
                      class="avatar-uploader"
                      action="http://localhost:9090/files/upload"
                      :show-file-list="true"
                      :on-success="handleAvatarSuccess"
                      :limit="1"
                  >
                    <i class="el-icon-plus avatar-uploader-icon"></i>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="6">
              </el-col>
              <el-col :span="6">

              </el-col>
            </el-row>
          </el-card>

        </el-tab-pane>

      </el-tabs>







    </el-form>

  </div>




</template>

<script>

import request from "@/utils/request";
import E from "wangeditor";

export default {
  name: 'News',
  components: {},
  data() {
    return {
      loading: true,
      form: {},
      rules: {},
      dialogVisible: false,
      search: '',
      userName:'',
      gangWei:'',
      dataTime:'',
      workYear:'',
      workGrop:'',
      graduationTime:'',
      salaryExpectation:'',
      graduationSchool:'',
      maJor:'',
      departMent:'',
      resumeFileid:'',
      resumeFileName:'',
      currentPage: 1,
      pageSize: 10,
      total: 0,
      tableData: [],
      labelPosition: "right",
      vis: false,
      detail: {},
      options: [{
        value: '选项1',
        label: '上海交行'
      }, {
        value: '选项2',
        label: '上海建行'
      }, {
        value: '选项3',
        label: '上海农行'
      }, {
        value: '选项4',
        label: '上海中行'
      }, {
        value: '选项5',
        label: '上海邮储'
      }],
      value: ''
    }
  },
  created() {
    this.load()
  },
  methods: {
    //文件上传 resumeFileName
    handleAvatarSuccess(res) {
      alert("输出看看"+JSON.stringify(res));
      this.form.avatar = res.data
      //alert("输出简历"+this.form.avatar);
      this.$message.success("上传成功")
      // this.update()
    },
    details(row) {
      this.detail = row
      this.vis = true
    },
    filesUploadSuccess(res) {
      alert("输出看看2"+JSON.stringify(res));
      console.log(res)
      this.form.cover = res.data
    },
    //查询
    load() {
      this.loading = true
      //alert("load/"+this.dataTime);
      request.get("/resume", {
        params: {
          pageNum: this.currentPage,
          pageSize: this.pageSize,
          userName: this.userName,
          gangWei:  this.gangWei,
          dataTime: this.dataTime,
          workYear: this.workYear,
          workGrop: this.workGrop
        }
      }).then(res => {
        this.loading = false
        this.tableData = res.data.records
        this.total = res.data.total
      })
    },
    //清空查询条件
    resetForm(form){
      //alert("resetForm="+form);
      this.userName='',
          this.gangWei='',
          this.dataTime='',
          this.workYear='',
          this.workGrop=''
      //this.$refs.form.resetFields();
    },
    //新增
    add() {
      this.dialogVisible = true
      this.form = {}

      this.$nextTick(() => {
        // 关联弹窗里面的div，new一个 editor对象
        if (!editor) {
          editor = new E('#div1')

          // 配置 server 接口地址
          editor.config.uploadImgServer = 'http://' + window.server.filesUploadUrl + ':9090/files/editor/upload'
          editor.config.uploadFileName = "file"  // 设置上传参数名称
          editor.create()
        }

        editor.txt.html("")

      })

    },
    //保存
    save() {
      this.form.content = editor.txt.html()  // 获取 编辑器里面的值，然后赋予到实体当中
      if (this.form.id) {  // 更新
        request.put("/resume", this.form).then(res => {
          console.log(res)
          if (res.code === '0') {
            this.$message({
              type: "success",
              message: "更新成功"
            })
          } else {
            this.$message({
              type: "error",
              message: res.msg
            })
          }
          this.load() // 刷新表格的数据
          this.dialogVisible = false  // 关闭弹窗
        })
      } else {  // 新增
        let userStr = sessionStorage.getItem("user") || "{}"
        let user = JSON.parse(userStr)
        this.form.author = user.nickName

        request.post("/resume", this.form).then(res => {
          console.log(res)
          if (res.code === '0') {
            this.$message({
              type: "success",
              message: "新增成功"
            })
          } else {
            this.$message({
              type: "error",
              message: res.msg
            })
          }

          this.load() // 刷新表格的数据
          this.dialogVisible = false  // 关闭弹窗
        })
      }

    },
    handleEdit(row) {
      this.form = JSON.parse(JSON.stringify(row))
      this.dialogVisible = true

      this.$nextTick(() => {
        // 关联弹窗里面的div，new一个 editor对象
        // 关联弹窗里面的div，new一个 editor对象
        if (!editor) {
          editor = new E('#div1')

          // 配置 server 接口地址
          editor.config.uploadImgServer = 'http://localhost:9090/files/editor/upload'
          editor.config.uploadFileName = "file"  // 设置上传参数名称
          editor.create()
        }

        editor.txt.html(row.content)
      })
    },
    handleDelete(id) {
      console.log(id)
      request.delete("/news/" + id).then(res => {
        if (res.code === '0') {
          this.$message({
            type: "success",
            message: "删除成功"
          })
        } else {
          this.$message({
            type: "error",
            message: res.msg
          })
        }
        this.load()  // 删除之后重新加载表格的数据
      })
    },
    handleSizeChange(pageSize) {   // 改变当前每页的个数触发
      this.pageSize = pageSize
      this.load()
    },
    handleCurrentChange(pageNum) {  // 改变当前页码触发
      this.currentPage = pageNum
      this.load()
    }
  }
}




</script>
<!--
<style lang="stylus" scoped>
-->

<style >
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 20px;
  color: #8c939d;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
}
.avatar {
  width: 78px;
  height: 78px;
  display: block;
}
/*/deep/.el-dialog {*/
/*  width: 70% !important;*/
/*  height: 60% !important;*/
/*  overflow: scroll;*/
/*}*/

/*/deep/.el-tabs__content {*/
/*  background: #f5fafe;*/
/*  height: 420px;*/
/*  overflow-y: scroll;*/

/*.el-tab-pane {*/
/*}*/
/*}*/

/*.el-textarea {*/
/*textarea {*/
/*  padding: 8px; // 设置文本框的 padding*/
/*height: $inputHeight; // 设置文本框的 height*/
/*font-size: $inputFontSize;*/
/*  line-height: 21px;*/
/*}*/
/*}*/

/*.shouliTab { // 表单框*/
/*padding: 10px;*/
/*  overflow-y: scroll;*/
/*  height: 100%;*/
/*}*/

/*.hr {*/
/*  width: 100%;*/
/*  height: 1px;*/
/*  background: #ccc;*/
/*  margin: 10px 0;*/
/*}*/
/*.el-card{*/
/*  padding:12px;*/
/*}*/
/*.detail {*/
/*p {*/
/*  padding-left: 10px;*/
/*  line-height: 30px;*/
/*  font-size: 16px;*/
/*  color: #606266;*/
/*}*/
/*}*/


</style>
